//  https://ac.nowcoder.com/acm/problem/235950

#include<iostream>
using namespace std;

const int N = 100 * 5;
int dp[N];
int w[N], v[N], pos;
int n, m;

int main()
{
    cin >> n >> m;
    for (int i = 1;i <= n;i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        int t = 1;
        while (x >= t)
        {
            pos++;
            w[pos] = t * y;
            v[pos] = t * z;
            x -= t;
            t *= 2;
        }
        if (x)
        {
            pos++;
            w[pos] = x * y;
            v[pos] = x * z;
        }

    }

    for (int i = 1;i <= pos;i++)
        for (int j = m;j >= w[i];j--)
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);

    cout << dp[m] << endl;
    return 0;
}